import time
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("http://www.bjhospital.net/")
driver.implicitly_wait(15)
driver.maximize_window()

driver.find_element(By.CLASS_NAME,'keyword').send_keys("骨科")
time.sleep(2)
driver.find_element(By.CLASS_NAME,'btn').click()
time.sleep(2)
driver.find_element(By.XPATH,"/html/body/div[4]/ul/li[1]/div[1]/h5/a").click()
time.sleep(2)
win = driver.window_handles
driver.switch_to.window(win[-1])
time.sleep(2)

text = driver.find_element(By.XPATH,"/html/body/div[1]/div[2]/div/ul/li[1]/a").text
print(f"通过text返回内容：{text}")
print(driver.current_url)
time.sleep(7)
